#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include<QMouseEvent>
#include<QDebug>
#include<QGraphicsDropShadowEffect>
#include<iostream>
#include<vector>
#include<btform.h>
#include<QJsonArray>
#include"volumetool.h"
#include "musiclist.h"
#include<QMediaPlayer>
#include<QMediaPlaylist>
#include "commonpage.h"
#include "lrcpage.h"
#include<QSqlDatabase>
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
    void  initUi();
    void  initSQLite();
   void initMusicList();
    void connectSignalAndSlots();
    void onBtFormClick(int id);
    QJsonArray RandomPicture();
    void initPlayer();
    void onPlayCliked();
    void onPlayStateChange();
    void onPlayUpCliked();
    void  onPlayDownCliked();
    void onPlaybackModeCliked();
    void onPlaybackModeChanged(QMediaPlaylist::PlaybackMode playbackMode);
    void onPlayAll(PageType pagetype);
    void playAllOfCommonPage(CommonPage* commonpage,int index);
    //播放歌曲
    void onPlayMusic();
    //最近播放设置
    void onCurrentIndexChange(int index);
    //设置音量
    void  setMusicSilence(int volum);

    void  MusicSilence(bool volum);
    //歌曲总时间
    void onDurationChanged(qint64 duation);
    //歌曲播放实时时间
    void positionChanged(qint64 duration);
    //进度条
    void onMusicSliderChanged(float value);
    //歌曲，歌手，封面图片同步
    void onMetaDataAvailableChangedChanged(bool available);
    //歌词
    void  onLrcWordCliced();
    //最大化，最小化
    void on_skin_cliked();
    void on_max_clicked();
    void on_min_clicked();
    //动画和播放页面对应
    void updateBtformAnimal();
     //系统托盘
    void quitQQMusic();




private:
    virtual void mousePressEvent(QMouseEvent* event)override;
    virtual void mouseMoveEvent(QMouseEvent* event)override;


private slots:
    void on_quit_clicked();

    void on_volume_clicked();

    void on_addlocal_clicked();
    void onUpdateLikeMusic(bool isLike, QString musicId);
    void playMusicIndex(CommonPage* page,int index);


   // void on_play_clicked();

    void on_skin_clicked();

public:
    QMediaPlayer* player;
 private:
    QMediaPlaylist* playList;


private:
    Ui::Widget *ui;
    QPoint dragPosition;
    std::vector<btForm*> bts;
    VolumeTool* volumeTool;
    MusicList musiclist;
    CommonPage* curPage;
    qint64 totaltime;
    int  curPlayMusicIndex;

    LrcPage* lrcpage;
    QPropertyAnimation* lrcAnimation;

    QSqlDatabase sqlite;
    bool isDrag;




};
#endif // WIDGET_H
